<!DOCTYPE html>
<html lang='zh-CN'>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>修改密码</title>
<link rel="icon" href="favicon.ico" type="image/ico">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/materialdesignicons.min.css" rel="stylesheet">
<link href="js/bootstrapvalidator/dist/css/bootstrapValidator.css" rel="stylesheet">
<link href="css/style.min.css" rel="stylesheet">
</head>
  
<body>
<div class="container-fluid p-t-15">
  
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-body">
          
          <form method="post" class="site-form" id="editPwdForm">
              <div class="form-group">
                <label for="password">旧密码</label>
                <input type="password" class="form-control" name="password" id="password" placeholder="输入账号的原登录密码" required>
              </div>
              <div class="form-group">
                <label for="newPwd">新密码</label>
                <input type="password" class="form-control" name="newPwd" id="newPwd" placeholder="输入新的密码" required>
              </div>
              <div class="form-group">
                <label for="confirmPwd">确认新密码</label>
                <input type="password" class="form-control" name="confirmPwd" id="confirmPwd" placeholder="请输入正确的新密码"
                       data-match="#newpassword" required>
              </div>
              <button type="button" class="btn btn-primary" id="saveFormBtn">修改密码</button>
          </form>
 
        </div>
      </div>
    </div>
    
  </div>
  
</div>
<!-- juqery核心插件 -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<!-- bootstrap核心插件 -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrapvalidator/dist/js/bootstrapValidator.js"></script>
<script type="text/javascript" src="js/zero2one/zero2one.version.js"></script>
<script type="text/javascript" src="js/zero2one/zero2one.core.js"></script>
<!-- bootstrap弹出框插件 -->
<script type="text/javascript" src="js/jquery.bootstrap.min.js"></script>
<script type="text/javascript">

    $('#editPwdForm').bootstrapValidator({
        fields: {
            password: {validators: {notEmpty: {message: '原密码不能为空'}}},
            newPwd: {validators: {notEmpty: {message: '新密码不能为空'}}},
            confirmPwd: {validators: {notEmpty: {message: '确认密码不能为空'},identical: {field: 'newPwd',message: '两次输入的密码不一致'}}}
        }
    });

    $("#saveFormBtn").click(function () {
       var bv = $('#editPwdForm').data('bootstrapValidator');
        bv.validate();
        if (bv.isValid()) {
            zero2one.request("/editPwd",$("#editPwdForm").serialize(),function (data) {
                    window.parent.location.href = "/logout";
            });
        }
    });

</script>
</body>
</html>